package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

/* Cette classe s'occupe de l'affichage de la fen�tre dans laquelle
 * on a un menu avec l'option "Placer une commande ..." 
 */
public class VueApplication extends JFrame {

	//boolean placerCommande = false;
	public VueApplication() {

		UiSupport.createApplicationFrame(this, "LAB4", 0, 0, CANEVAS_LARGEUR
				+ MARGE_H, CANEVAS_HAUTEUR + MARGE_V);

		createFileMenus();

		setVisible(true);
	}

	/* Load menus */
	private void createFileMenus() {
		
		menuPlacerCommande = menu.getItem(0);
		menuQuit = menu.getItem(1);
		menuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
				ActionEvent.CTRL_MASK));

	}


	public void addPlacerCommandeListener(ActionListener listener){
		menuPlacerCommande.addActionListener(listener);
	}
	
	public void addQuitListener(ActionListener listener){
		menuQuit.addActionListener(listener);
	}
	
	public JMenu getMenu(){
		return menu;
	}
	//public boolean isCommande(){
	//	return placerCommande;
	//}
	
	
	
	private JMenuItem menuPlacerCommande, menuQuit;
	private static final long serialVersionUID = -3535118786934945940L;
	private static final int CANEVAS_HAUTEUR = 600;
	private static final int CANEVAS_LARGEUR = 864;
	private static final int MARGE_H = 50;
	private static final int MARGE_V = 60;
	JMenu menu = UiSupport.addMenu(this, "File", new String[] {
			"Placer commande...", "Quit" });
}
